package com.ruiya.staging.goods.cas.mapper;

import com.ruiya.staging.goods.cas.model.GoodsInfoVO;
import com.ruiya.staging.goods.data.grpc.GoodsInfo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface GoodsInfoVOMapper {
    GoodsInfoVOMapper INSTANCE = Mappers.getMapper(GoodsInfoVOMapper.class);

    GoodsInfoVO mapToGoodsInfoVO(GoodsInfo goodsInfo);

    @Mappings({
            @Mapping(target = "approvalNo",  defaultValue = ""),
            @Mapping(target = "barcode", defaultValue = ""),
            @Mapping(target = "goodsHabitat", defaultValue = ""),
            @Mapping(target = "goodsPicture", defaultValue = ""),
            @Mapping(target = "goodsSpecs", defaultValue = ""),
            @Mapping(target = "dosage", defaultValue = ""),
            @Mapping(target = "goodsTag", defaultValue = ""),
            @Mapping(target = "goodsUnit", defaultValue = ""),
            @Mapping(target = "manufacturer", defaultValue = ""),
            @Mapping(target = "note", defaultValue = ""),
            @Mapping(target = "pinyinInitial", defaultValue = ""),
            @Mapping(target = "platformCode", defaultValue = ""),
            @Mapping(target = "status", defaultValue = ""),
            @Mapping(target = "creator", defaultValue = ""),
            @Mapping(target = "lastModifier", defaultValue = ""),
            //ignore grpc generated redundant properties
            @Mapping(target = "mergeFrom", ignore = true),
            @Mapping(target = "clearField", ignore = true),
            @Mapping(target = "clearOneof", ignore = true),
            @Mapping(target = "entIdBytes", ignore = true),
            @Mapping(target = "goodsIdBytes", ignore = true),
            @Mapping(target = "goodsNoBytes", ignore = true),
            @Mapping(target = "goodsNameBytes", ignore = true),
            @Mapping(target = "approvalNoBytes", ignore = true),
            @Mapping(target = "barcodeBytes", ignore = true),
            @Mapping(target = "goodsHabitatBytes", ignore = true),
            @Mapping(target = "goodsPictureBytes", ignore = true),
            @Mapping(target = "goodsSpecsBytes", ignore = true),
            @Mapping(target = "dosageBytes", ignore = true),
            @Mapping(target = "goodsTagBytes", ignore = true),
            @Mapping(target = "goodsUnitBytes", ignore = true),
            @Mapping(target = "manufacturerBytes", ignore = true),
            @Mapping(target = "noteBytes", ignore = true),
            @Mapping(target = "pinyinInitialBytes", ignore = true),
            @Mapping(target = "platformCodeBytes", ignore = true),
            @Mapping(target = "statusBytes", ignore = true),
            @Mapping(target = "creatorBytes", ignore = true),
            @Mapping(target = "lastModifierBytes", ignore = true),
            @Mapping(target = "unknownFields", ignore = true),
            @Mapping(target = "mergeUnknownFields", ignore = true),
            @Mapping(target = "allFields", ignore = true)
    })
    GoodsInfo mapFromGoodsInfoVO(GoodsInfoVO goodsInfoVO);

}
